package controller.user.shoppingCart;

import context.BaseContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import model.entity.ShoppingCart;
import service.Impl.ShopCartServiceImpl;
import util.ResultUtil;

import java.io.IOException;
import java.util.List;

@WebServlet("/user/shoppingCart/list")
public class ShopCartListController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ShopCartServiceImpl service=new ShopCartServiceImpl();
        List<ShoppingCart> carts=service.get(BaseContext.getCurrentId());
        String json= ResultUtil.getJSON(carts);
        resp.getWriter().write(json);
    }
}
